#include <iostream>
using namespace std;

int check(int n)
{
    int r = 0;
    if (n < 10)
    {
        if (n == 2)  r++;
    }
    else
    {
        if (n % 10 == 2) r++;
        n /= 10;
        r += check(n);
    }
    return r;
}

int main()
{
    int a, b;
    int res = 0;
    cin >> a >> b;
    int n = b - a + 1;
    int m[n];
    for (int q = 0; q < n; q++)
    {
        m[q] = a + q;
        if (check(m[q]) != 0)  res += check(m[q]);
    }
    printf("%d", res);
    return 0;
}